import request from "../utils/request";

export function getAccount() {
  return request({
    url: "/view_api/users/getUsers"
  });
}

export function updateAccount(data) {
  return request({
    url: "/view_api/users/updateUsers",
    method: "post",
    data,
    _loading: true
  });
}

export function createUserProject(data) {
  return request({
    url: "/view_api/userProject/createUserProject",
    method: "post",
    data,
    _loading: true
  });
}

export function updateUserProject(data) {
  return request({
    url: "/view_api/userProject/updateUserProject",
    method: "post",
    data,
    _loading: true
  });
}

export function getAccountNews() {}

export function register(data) {
  return request({
    url: "/view_api/users/createUsers",
    method: "post",
    data
  });
}

export function login(params) {
  return request({
    url: "/view_api/users/login",
    params
  });
}

export function getProjectDetail(ID) {
  return request({
    url: "/view_api/userProject/getProjectById",
    params: {
      ID
    }
  });
}

export function getConfig() {
  return request({
    url: "/view_api/get_config"
  });
}

export function getCode({ phone, type }) {
  return request({
    url: "/view_api/send_msg",
    params: {
      phone,
      type
    }
  });
}

export function updateStore(data) {
  const path = data.ID ? "updateIndex" : "addIndex";
  return request({
    url: "/view_api/user_index/" + path,
    method: "post",
    data
  });
}

export function updateGoods(data) {
  const path = data.ID ? "UpdateUserGoods" : "AddUserGoods";
  return request({
    url: "/view_api/user_goods/" + path,
    method: "post",
    data
  });
}

export function getStore(params) {
  return request({
    url: "/view_api/user_index/userIndex",
    params
  });
}

export function getStoreList(params) {
  return request({
    url: "/view_api/users/getUserList",
    params
  });
}

export function getGoods({ userId, cWork, cProduct, status }) {
  return request({
    url: "/view_api/user_goods/GetUserGoodsList",
    params: {
      userId,
      cWork,
      cProduct,
      status
    }
  });
}

export function deleteGoods(data) {
  return request({
    url: "view_api/user_goods/deleteUserGoods",
    method: "post",
    data
  });
}

export function createOrder(data) {
  const path = data.ID ? "UpdateOrder" : "createOrder";
  return request({
    url: "/view_api/user_order/" + path,
    method: "post",
    data
  });
}

export function getOrders(params) {
  return request({
    url: "/view_api/user_order/list",
    method: "get",
    params
  });
}

export function getOrdersList(params = {}) {
  return request({
    url: "/view_api/user_order/userOrderDetailList",
    params
  });
}
